You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this is invalid behavior from CSS spec point of view and this hack leads different result from Firefox and Safari. Firefox and Safari do not override white-space style and use <br> instead when inserting a line break. And also they use pairs of an NBSP and an ASCII space if multiple collapsible white-spaces are typed consecutively. I.e., these behaviors are same as contenteditable=true if white-space style does not preserve line breaks and/or consecutive white-spaces.
In other words, Chrome/Chromium's hack leads web-compat issue between browsers.
If the web app wants to retrieve the input values of contenteditable=plaintext-only with Element.textContent, the web app should specify white-space: pre or white-space: pre-wrap explicitly. Then, web apps do not need to take care of this incompatibility.
What did you expect to see?
So first, there should be a note that explains what Chrome/Chromium does. Their hack makes web apps access the result with Element.textContent easier, but web apps cannot use white-space: normal, etc for plaintext-only.
And then, recommend to specify white-space style to pre-wrap or pre explicitly.
Do you have any supporting links, references, or citations?
caugner
changed the title
Add a note about white-space style hack of Chrome/Chromium when contenteditable=plaintext-only
html.global_attributes.contenteditable - Add note about white-space style hack of Chrome/Chromium when contenteditable=plaintext-onlyMay 6, 2025
@masayuki-nakano Thanks for reporting. Would you like to open a PR adding notes to that Chrome support statement, explalining how white-space styles are replaced with this feature?
MDN URL
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/contenteditable
What specific section or headline is this issue about?
"paintext-only" definition in the "Value" section should have a note
What information was incorrect, unhelpful, or incomplete?
Currently, Chrome/Chromium has a hack for
white-space
style whencontenteditable
value isplaintext-only
. That is, they override the specified (or implicit)white-space
style topre-wrap
orpre
.https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/css/resolver/style_adjuster.cc;l=405-415;drc=3a3c641c8597f54a4eb6286d816f52b8a649c8bf
And they always use
\n
as a line break instead of<br>
and never use NBSPs when user types white-spaces consecutively.However, this is invalid behavior from CSS spec point of view and this hack leads different result from Firefox and Safari. Firefox and Safari do not override
white-space
style and use<br>
instead when inserting a line break. And also they use pairs of an NBSP and an ASCII space if multiple collapsible white-spaces are typed consecutively. I.e., these behaviors are same ascontenteditable=true
ifwhite-space
style does not preserve line breaks and/or consecutive white-spaces.In other words, Chrome/Chromium's hack leads web-compat issue between browsers.
If the web app wants to retrieve the input values of
contenteditable=plaintext-only
withElement.textContent
, the web app should specifywhite-space: pre
orwhite-space: pre-wrap
explicitly. Then, web apps do not need to take care of this incompatibility.What did you expect to see?
So first, there should be a note that explains what Chrome/Chromium does. Their hack makes web apps access the result with
Element.textContent
easier, but web apps cannot usewhite-space: normal
, etc forplaintext-only
.And then, recommend to specify
white-space
style topre-wrap
orpre
explicitly.Do you have any supporting links, references, or citations?
Do you have anything more you want to share?
Nothing special.
MDN metadata
Page report details
en-us/web/html/reference/global_attributes/contenteditable
The text was updated successfully, but these errors were encountered: